package com.zb.hms.business.web.exception.resolver;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zb.hms.base.util.messageUtil.ExceptionMessage;


@ControllerAdvice
public class CustomMappingExceptionResolver  {
	@Resource
	private ExceptionMessage exceptionMessage;
	@ExceptionHandler()
	@ResponseBody	
	public ExceptionMessage resolveException(HttpServletRequest request,
			HttpServletResponse response, Object handler, Exception ex) {
		// TODO Auto-generated method stub
		exceptionMessage.setType("exception");
		exceptionMessage.setStatus(500);
		exceptionMessage.setMessage("服务器处理异常!");
		exceptionMessage.setExceptionClass(ex.getClass().toString());
		exceptionMessage.setExceptionMessage(ex.getMessage());
		return exceptionMessage;
	}

}
